﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using PhoneBook.Extensions;
using PhoneBook.Models.UserGroups;
using PhoneBook.Service.UserGroups;

namespace PhoneBook.Controllers
{
    public class UserGroupsController : Controller
    {
        private IUserGroupService _userGroupService;

        public UserGroupsController(IUserGroupService userGroupService)
        {
            _userGroupService = userGroupService;
        }


        public ActionResult Index()
        {
            return View();
        }


     


        public JsonResult AddNewUserGroup(UserGroupAddOrEditModel model)
        {
            var userGroup = model.ToEntity();
            _userGroupService.AddUserGroup(userGroup);
            return Json(new { status="success", GroupName = model.GroupName, GroupId = userGroup.Id});
        }
      
    }
}
